<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  request.setAttribute("now",new Date());
%>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading header">
                <h3 class="panel-title" id="title">资产入库登记表</h3>
            </div>

            <div style="margin: 10px">

                <!-- Nav tabs -->
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#bsc-tab-1" data-toggle="tab">资产信息</a></li>
                </ul>

                <!-- Tabs Content -->
                <div class="tab-content">

                    <div class="tab-pane pad-btm fade in active" id="bsc-tab-1">
                        <!-- BASIC FORM ELEMENTS -->
                        <!--===================================================-->
                        <form id="form_asset_input" class="panel-body form-horizontal form-padding">
                            <input type="hidden" name="keyId" id="keyId" value="${asset.id}" />
                            <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产编号<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="assetNo" name="assetNo" class="form-control" value="${asset.assetNo}" >
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产名称<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="name" name="name" class="form-control" value="${asset.name}" >
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产品牌<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="brand" name="brand" class="form-control" value="${asset.brand}" >
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">规则型号<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="model" name="model" class="form-control" value="${asset.model}" >
                                </div>
                            </div>


                            <div class="form-group div-Hidden">
                                <label class="col-md-2 control-label">采购日期<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <div class="input-group date">
                                        <input type="text" class="form-control" id="datPurchase" name="datPurchase" disabled
                                               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${asset.datPurchase}" /> >
                                        <span class="input-group-addon"><i class="ti-calendar"></i></span>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">采购金额<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="number" id="purchaseMoney" name="purchaseMoney" class="form-control" value="${asset.purchaseMoney}" readonly>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">提交人</label>
                                <div class="col-md-2">
                                    <p class="form-control-static">${asset.creater.name}</p>
                                </div>
                                <label class="col-md-2 control-label">提交日期</label>
                                <div class="col-md-2">
                                    <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${asset.dateApply}" /></p>
                                </div>
                            </div>

                            <div class="panel-footer">
                                <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
                                    <i class="fa fa-lg fa-mail-reply"></i> 返回
                                </a>
                                <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
                                <c:if test="${asset.numStatus==0 || asset.processState=='Draft'}">
                                    <a class="btn btn-warning" id="btn-commit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
                                </c:if>
                                <c:if test="${asset!=null && asset.processState=='Backed'}">
                                    <a class="btn btn-warning" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
                                </c:if>
                                <c:if test="${asset.numStatus==1}">
                                    <a class="btn btn-warning" id="btn-finish-common" href="javascript:void(0);"><i class="fa fa-check"></i> 采购完成 </a>
                                </c:if>
                            </div>

                        </form>

                        <!--===================================================-->
                        <!-- END BASIC FORM ELEMENTS -->

                    </div>

                </div>
            </div>

        </div>
    </div>
</div>

<script>
    var index = "${index}";
    var todo = "${todo}";
    var remind = "${remind}";
    var record = "${record}";
    var draft =  "${draft}";

    $(function(){
        var pdata= {
            keyId:$("#keyId").val(),
            entityName:"com.fz.us.oa.core.entity.com.Asset"
        };
        multiDuty(pdata);
    });

    //校验
    function infoValidate() {
        var tmp = "";

        tmp = $("input#assetNo").val();
        if(!tmp){
            __toastr_error("请输入资产编号！");
            return false;
        }

        tmp = $("input#name").val();
        if(!tmp){
            __toastr_error("请输入资产名称！");
            return false;
        }

        tmp = $("input#brand").val();
        if(!tmp){
            __toastr_error("请输入资产品牌！");
            return false;
        }

        tmp = $("input#model").val();
        if(!tmp){
            __toastr_error("请输入规则型号！");
            return false;
        }

        return true;
    }

    //保存
    $("#btn-save-common").click(
            function(e) {
                __confirm_dialog("提示：","确定保存吗？",
                        function () {
                            __form_save("form_asset_input", "<%=path%>/com/asset/save",function(){
                                $("#apply-re-common").trigger("click");
                            });
                        }
                )
            }
    );

    //提交
    $("#btn-commit-common,#btn-recommit-common").click(
        function(e) {
            var $valid = infoValidate();
            if(!$valid) return false;

            __confirm_dialog("提示：","提交后填写资料不得修改，请确认是否进行提交？",
                function () {
                    __form_save("form_asset_input", "<%=path%>/com/asset/commit",function(){
                        $("#apply-re-common").trigger("click");
                    });
                }
            )
        }
    );

    //返回视图
    $("#apply-re-common").click(function(){

        if(index==1){
            loadURL("menu/dashboard",$('#page-content'));
        }else if(todo==1){
            loadURL("menu/toDo",$('#page-content'));
        }else if(remind==1){
            loadURL("menu/remind",$('#page-content'));
        }else if(record==1){
            loadURL("menu/taskRecord?type=1",$('#page-content'));
        }else if(record==2){
            loadURL("menu/taskRecord?type=2",$('#page-content'));
        }else if(draft==1){
            loadURL("menu/draft",$('#page-content'));
        }else{
            returnToHashUrl()
        }
    });

</script>
